package com.ruoyi.project.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.project.domain.A07Training;
import com.ruoyi.project.service.IA07TrainingService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;

/**
 * 培训项目Controller
 * 
 * @author WorrilessGo
 * @date 2025-11-19
 */
@RestController
@RequestMapping("/traningProject")
public class A07TrainingController extends BaseController
{
    @Autowired
    private IA07TrainingService a07TrainingService;

    /**
     * 查询培训项目列表
     */
    @RequiresPermissions("trainingProject:project:list")
    @GetMapping("/list")
    public AjaxResult list(A07Training a07Training)
    {
        List<A07Training> list = a07TrainingService.selectA07TrainingList(a07Training);
        return success(list);
    }

    /**
     * 导出培训项目列表
     */
    @RequiresPermissions("project:trainingProject:export")
    @Log(title = "培训项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, A07Training a07Training)
    {
        List<A07Training> list = a07TrainingService.selectA07TrainingList(a07Training);
        ExcelUtil<A07Training> util = new ExcelUtil<A07Training>(A07Training.class);
        util.exportExcel(response, list, "培训项目数据");
    }

    /**
     * 获取培训项目详细信息
     */
    @RequiresPermissions("project:trainingProject:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(a07TrainingService.selectA07TrainingById(id));
    }

    /**
     * 新增培训项目
     */
    @RequiresPermissions("project:trainingProject:add")
    @Log(title = "培训项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody A07Training a07Training)
    {
        return toAjax(a07TrainingService.insertA07Training(a07Training));
    }

    /**
     * 修改培训项目
     */
    @RequiresPermissions("project:trainingProject:edit")
    @Log(title = "培训项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody A07Training a07Training)
    {
        return toAjax(a07TrainingService.updateA07Training(a07Training));
    }

    /**
     * 删除培训项目
     */
    @RequiresPermissions("project:trainingProject:remove")
    @Log(title = "培训项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(a07TrainingService.deleteA07TrainingByIds(ids));
    }
}
